{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 15398 entries, 0 to 15397\n",
      "Data columns (total 12 columns):\n",
      "invited           15398 non-null int64\n",
      "userCF_reco       15395 non-null float64\n",
      "evtCF_reco        15393 non-null float64\n",
      "svdCF_reco        15398 non-null float64\n",
      "user_reco         15398 non-null float64\n",
      "evt_p_reco        15398 non-null float64\n",
      "evt_c_reco        15398 non-null float64\n",
      "user_pop          15398 non-null float64\n",
      "frnd_infl         15398 non-null float64\n",
      "evt_pop           15398 non-null float64\n",
      "interested        15398 non-null int64\n",
      "not_interested    15398 non-null int64\n",
      "dtypes: float64(9), int64(3)\n",
      "memory usage: 1.4 MB\n"
     ]
    }
   ],
   "source": [
    "# 将所有特征串联起来，构成RS_Train.csv\n",
    "#RS_Test.csv\n",
    "#为最后推荐系统做准备\n",
    "import pandas as pd\n",
    "\n",
    "rs_train = pd.read_csv(\"RS_train.csv\")\n",
    "rs_train.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (<ipython-input-58-6b5caeddd0b9>, line 2)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  File \u001b[1;32m\"<ipython-input-58-6b5caeddd0b9>\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m    print(\"给予用户协同过滤 准确率\", rs_train.loc[rs_train[\"userCF_reco\"] > = 0.5].loc[rs_train[\"interested\"] == 1].shape[0] / 15398)\u001b[0m\n\u001b[1;37m                                                                 ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "print(\"给予用户协同过滤 准确率\", rs_train.loc[rs_train[\"userCF_reco\"] > = 0.5].loc[rs_train[\"interested\"] == 1].shape[0] / 15398)\n",
    "print(\"给予用户协同过滤 召回率\", rs_train.loc[rs_train[\"userCF_reco\"] < 0.5].loc[rs_train[\"userCF_reco\"] != -2].loc[rs_train[\"interested\"] == 0].shape[0] / 15398)\n",
    "print(\"给予用户协同过滤 无法判断\", rs_train.loc[rs_train[\"userCF_reco\"] == -2].shape[0] / 15398)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "给予物品协同过滤 准确率 0.17515261722301598\n",
      "给予物品协同过滤 准确率 0.6997012599038837\n",
      "给予物品协同过滤 无法判断 0.08228341343031563\n"
     ]
    }
   ],
   "source": [
    "print(\"给予物品协同过滤 准确率\", rs_train.loc[rs_train[\"evtCF_reco\"] >= 0.5].loc[rs_train[\"interested\"] == 1].shape[0] / 15398)\n",
    "print(\"给予物品协同过滤 准确率\", rs_train.loc[rs_train[\"evtCF_reco\"] < 0.5].loc[rs_train[\"evtCF_reco\"] != -2].loc[rs_train[\"interested\"] == 0].shape[0] / 15398)\n",
    "print(\"给予物品协同过滤 无法判断\", rs_train.loc[rs_train[\"evtCF_reco\"] == -2].shape[0] / 15398)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.2263930380568905"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rs_train.loc[(rs_train[\"userCF_reco\"]>= 0.5) | (rs_train[\"evtCF_reco\"]>=0.5)].loc[rs_train[\"interested\"] == 1].shape[0] / 15398"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7315235744901936"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rs_train.loc[(rs_train[\"userCF_reco\"]< 0.5) | (rs_train[\"evtCF_reco\"] < 0.5)].loc[rs_train[\"interested\"] == 0].shape[0] / 15398"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
